package view.component.window
{
import flash.display.MovieClip;
import flash.geom.Point;

import framework.core.popup.PopUpManager;
import framework.proxy.ComponentProxy;
import framework.view.components.button.ButtonProxy;

/**
 * WindowProxy
 * @author jliang
 *
 */
public class WindowProxy extends ComponentProxy
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function WindowProxy()
	{
		super();
	}
	//==========================================================================
	//  Properties
	//==========================================================================	
	protected var _component:WindowComponent;

	public function get component():WindowComponent
	{
		return _component;
	}

	public function set component(value:WindowComponent):void
	{
		_component = value;
	}
	
	protected function get closeBtn():ButtonProxy
	{
		return proxys["closeBtn"];
	}
	
	override protected function get proxyMapping():Array
	{
		return [ 
			{ skin:"closeBtn", classRef: ButtonProxy, id:"closeBtn", onClick: clickToCloseHandler }
		].concat(super.proxyMapping);
	}	
	
	override public function parse(target:MovieClip):void
	{
		super.parse(target);
	}
	//==========================================================================
	//  Public methods
	//==========================================================================
	public function show(lock:Boolean = true, position:Point = null, ...args):void
	{
		PopUpManager.show(component, position ? false : true, position, lock);
	}
	
	public function close():void
	{
		PopUpManager.close(component);
	}
	//==========================================================================
	//  Event handlers
	//==========================================================================
	protected function clickToCloseHandler():void
	{
		close();
	}
}
}




